from selenium import webdriver
from selenium.webdriver.common.by import By
import time
# 创建浏览器驱动对象
driver = webdriver.Chrome()
# 加载web页面
driver.get("http://121.43.169.97:8848/pageA.html")

# 4.页面操作:通过标签名定位页面元素

# driver.find_element(By.XPATH,"//input[@name='userA']").send_keys("admin")
# driver.find_element(By.XPATH,"//input[@id='passwordA']").send_keys("123456")
# driver.find_element(By.XPATH,"//input[@id='telA']").send_keys("13855555555")
# 属性与逻辑结合
# driver.find_element(By.XPATH,"//input[@type='button' and @value='prompt']").click()
# 层级和属性定位
# driver.find_element(By.XPATH,"//p[@id='pa']/input[@type='text']").send_keys("admin")
# driver.find_element(By.XPATH,"//p/input[@id='passwordA']").send_keys("admin")
# 利用元素文本定位
# driver.find_element(By.XPATH,".//a[text()='百度']").click()
# 利用局部属性值定位
driver.find_element(By.XPATH, "//*[contains(@placeholder,'用户名')]").send_keys("admin2")

# 暂停3秒
time.sleep(3)
# 关闭驱动对象
driver.quit()